package com.beans;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: H_tao_X
 * Date: 2022-11-17
 * Time: 21:16
 */

/**
 * 通过 setter 注入
 */
@Controller
public class UserController4 {
    // 1.先定义 注入的 对象
    private Service service;
    @Autowired
    // 2. 提供 setter 方法
    public void setService(Service service) {
        this.service = service;
    }
    public void sayHi() {
        service.sayHi();
    }
}
